import React from 'react'
import {HashRouter, Route, Switch} from 'react-router-dom'
import {hot} from 'react-hot-loader'
import BasicLayout from './layouts/BasicLayout'
import Login from './components/Login'

class BasicRoute extends React.Component {
  constructor() {
    super()
    this.state = {
      isLogin: false,
    }
  }

  componentWillMount() {
    const isLogin = sessionStorage.getItem("isLogin")
    this.setState({ isLogin })
  }

  render() {
    const { isLogin } = this.state
    console.log(isLogin)
    return (
      <HashRouter>
        <Switch>
          <Route strict path="/login" component={Login} />
          <Route path="/" component={BasicLayout} />
        </Switch>
      </HashRouter>
    )
  }
}

export default hot(module)(BasicRoute)